package com.beiye.drivertransport.thematic.learning;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.SubActivity.TakePhotoScrolls1Activity;
import com.beiye.drivertransport.activity.TwoBaseAty;
import com.beiye.drivertransport.adapter.LearnCarAdapter;
import com.beiye.drivertransport.bean.LoginUserBean;
import com.beiye.drivertransport.bean.MineUseBean;
import com.beiye.drivertransport.http.Login;
import com.beiye.drivertransport.thematic.learning.test.TestthematiclearningActivity;
import com.beiye.drivertransport.utils.MessageEvent;
import com.beiye.drivertransport.utils.UserManger;
import com.squareup.picasso.Picasso;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.TimerTask;


import butterknife.OnClick;
import es.dmoral.toasty.Toasty;
import okhttp3.Call;
import okhttp3.Response;

//专题培训界面
public class ThematiclearningActivity extends TwoBaseAty {


    TabLayout TabLayout2;

    ViewPager myviewpager;

    ImageView img_back;

    ImageView img_thematicle;

    TextView tv_thembgm;

    TextView tv_thembgm1;

    TextView tv_thembgm3;

    LinearLayout le_thematic;//模式1三块菜单

    LinearLayout le_thematic1;//模式2四块菜单

    LinearLayout le_thematic2;//模式3两块菜单

    LinearLayout le_thematic3;//模式4一块菜单

    TextView tv_thembgm4;

    TextView tv_thembgm5;

    TextView tv_thembgm6;

    TextView tv_thembgm7;

    TextView tv_thembgm8;

    TextView tv_thembgm9;

    TextView tv_thembgm10;
    private ArrayList<Fragment> fragments;
    private ArrayList<String> list_title;
    private LearnCarAdapter adapter;
    private static int TAB_MARGIN_DIP = 25;//三块
    private static int TAB_MARGIN_DIP1 = 15;//四块
    private static int TAB_MARGIN_DIP2 = 35;//两块
    private static int TAB_MARGIN_DIP3 = 45;//一块
    ArrayList<Integer> marklist = new ArrayList<>();


    @Override
    public int getLayoutId() {
        return R.layout.activity_thematiclearning;

    }

    public void onClick(View view) {
        if (view.getId() == R.id.img_back) {
            finish();
        }

    }

    @Override
    public void initData() {
        TabLayout2 = (TabLayout) findViewById(R.id.tab_FindFragment_title2);
        myviewpager = (ViewPager) findViewById(R.id.myviewpager);
        img_back = (ImageView) findViewById(R.id.img_back);
        img_thematicle = (ImageView) findViewById(R.id.img_thematicle);
        tv_thembgm = (TextView) findViewById(R.id.tv_thembgm);
        tv_thembgm1 = (TextView) findViewById(R.id.tv_thembgm1);
        tv_thembgm3 = (TextView) findViewById(R.id.tv_thembgm3);
        le_thematic = (LinearLayout)findViewById(R.id.le_thematic);
        le_thematic1 = (LinearLayout)findViewById(R.id.le_thematic1);
        le_thematic2 = (LinearLayout)findViewById(R.id.le_thematic2);
        le_thematic3 = (LinearLayout)findViewById(R.id.le_thematic3);
        tv_thembgm4 = (TextView) findViewById(R.id.tv_thembgm4);
        tv_thembgm5 = (TextView) findViewById(R.id.tv_thembgm5);
        tv_thembgm6 = (TextView) findViewById(R.id.tv_thembgm6);
        tv_thembgm7 = (TextView) findViewById(R.id.tv_thembgm7);
        tv_thembgm8 = (TextView) findViewById(R.id.tv_thembgm8);
        tv_thembgm9 = (TextView) findViewById(R.id.tv_thembgm9);
        tv_thembgm10 = (TextView) findViewById(R.id.tv_thembgm10);
        // StatusBarCompat.setStatusBarColor(this, Color.parseColor("#fecc01"));
        if (Build.VERSION.SDK_INT >= 21) {
            View decorView = getWindow().getDecorView();
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }


        Bundle bundle = getIntent().getExtras();
        String orgId = bundle.getString("orgId");
        String orgName = bundle.getString("orgName");
        String iconUrl2 = bundle.getString("iconUrl");
        int stId = bundle.getInt("stId");
        String rolename = bundle.getString("rolename");
        String adId = bundle.getString("adId");
        int position = bundle.getInt("position");
        int ihveMark = bundle.getInt("ihveMark");
        int tmenuMark = bundle.getInt("tmenuMark");
        int qmenuMark = bundle.getInt("qmenuMark");
        int peMenuMark = bundle.getInt("peMenuMark");
        int emenuMark = bundle.getInt("emenuMark");
        int seqTMark = bundle.getInt("seqTMark");
        int reapplyMark=bundle.getInt("reapplyMark");

        if (iconUrl2 != null) {
            Picasso.with(ThematiclearningActivity.this).load(Uri.parse(iconUrl2)).placeholder(R.mipmap.no_data2).into(img_thematicle);
        }
        SharedPreferences sp = getSharedPreferences("ThematiclearningActivity",
                Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putInt("tmenuMark", tmenuMark);
        edit.putInt("qmenuMark", qmenuMark);
        edit.putInt("peMenuMark", peMenuMark);
        edit.putInt("emenuMark", emenuMark);
        edit.commit();
        marklist.clear();
        if (tmenuMark == 1) {
            marklist.add(1);
        }
        if (qmenuMark == 1) {
            marklist.add(1);
        }
        if (peMenuMark == 1) {
            marklist.add(1);
        }
        if (emenuMark == 1) {
            marklist.add(1);
        }
        if (marklist.size() == 0) {
            le_thematic.setVisibility(View.GONE);
            le_thematic1.setVisibility(View.GONE);
            le_thematic2.setVisibility(View.GONE);
            le_thematic3.setVisibility(View.GONE);
            TabLayout2.setVisibility(View.GONE);
            myviewpager.setVisibility(View.GONE);
        } else if (marklist.size() == 1) {
            le_thematic.setVisibility(View.GONE);
            le_thematic1.setVisibility(View.GONE);
            le_thematic2.setVisibility(View.GONE);
            le_thematic3.setVisibility(View.VISIBLE);
            TabLayout2.setVisibility(View.VISIBLE);
            myviewpager.setVisibility(View.VISIBLE);
            int tmenuMark1 = sp.getInt("tmenuMark", 0);
            int qmenuMark1 = sp.getInt("qmenuMark", 0);
            int peMenuMark1 = sp.getInt("peMenuMark", 0);
            int emenuMark1 = sp.getInt("emenuMark", 0);
            if (tmenuMark1 == 1 && qmenuMark1 != 1 && peMenuMark1 != 1 && emenuMark1 != 1) {
                fragments = new ArrayList<Fragment>();
                LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
                fragments.add(learnthematiclearningFragment);
//                 ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//                 fragments.add(exercisesthematiclearingFragment);
//        TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
//        fragments.add(testthematiclearningFragment);
//                 ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//                 fragments.add(examinationthematiclearningFragment);

                Bundle args1 = new Bundle();
                args1.putInt("stId", stId);
                args1.putString("orgId", orgId);
                args1.putString("rolename", rolename);
                args1.putString("adId", adId);
                args1.putInt("position", position);
                args1.putInt("seqTMark", seqTMark);
                args1.putInt("reapplyMark",reapplyMark);
                learnthematiclearningFragment.setArguments(args1);
//                 Bundle args2 = new Bundle();
//                 args2.putInt("stId", stId);
//                 exercisesthematiclearingFragment.setArguments(args2);
//        Bundle args3 = new Bundle();
//        args3.putInt("stId", stId);
//        args3.putString("orgId", orgId);
//        testthematiclearningFragment.setArguments(args3);
//                 Bundle args4 = new Bundle();
//                 args4.putInt("stId", stId);
//                 args4.putString("orgId", orgId);
//                 args4.putString("orgName", orgName);
//                 args4.putString("rolename", rolename);
//                 args4.putString("adId", adId);
//                 args4.putInt("position", position);
//                 args4.putInt("ihveMark", ihveMark);
//                 examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                list_title.add("学习");
                //list_title.add("习题练习");
                // list_title.add("测验");
                // list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(1);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("学习")) {
                            tv_thembgm10.setBackgroundResource(R.drawable.tab_thempress);
                            //tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        }
//                         else if (textView.getText().toString().trim().equals("习题练习")) {
//                             tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
//                         }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 != 1 && qmenuMark1 == 1 && peMenuMark1 != 1 && emenuMark1 != 1) {
                fragments = new ArrayList<Fragment>();

                ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
                fragments.add(exercisesthematiclearingFragment);
                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                exercisesthematiclearingFragment.setArguments(args2);
//        Bundle args3 = new Bundle();
//        args3.putInt("stId", stId);
//        args3.putString("orgId", orgId);
//        testthematiclearningFragment.setArguments(args3);
//                 Bundle args4 = new Bundle();
//                 args4.putInt("stId", stId);
//                 args4.putString("orgId", orgId);
//                 args4.putString("orgName", orgName);
//                 args4.putString("rolename", rolename);
//                 args4.putString("adId", adId);
//                 args4.putInt("position", position);
//                 args4.putInt("ihveMark", ihveMark);
//                 examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                // list_title.add("学习");
                list_title.add("习题练习");
                // list_title.add("测验");
                // list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(1);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("习题练习")) {
                            tv_thembgm10.setBackgroundResource(R.drawable.tab_thempress);
                            //tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        }
//                         else if (textView.getText().toString().trim().equals("习题练习")) {
//                             tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
//                         }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 != 1 && qmenuMark1 != 1 && peMenuMark1 == 1 && emenuMark1 != 1) {
                fragments = new ArrayList<Fragment>();

                TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
                fragments.add(testthematiclearningFragment);
//                 ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//                 fragments.add(examinationthematiclearningFragment);

//                 Bundle args1 = new Bundle();
//                 args1.putInt("stId", stId);
//                 args1.putString("orgId", orgId);
//                 args1.putString("rolename", rolename);
//                 args1.putString("adId", adId);
//                 args1.putInt("position", position);
//                 learnthematiclearningFragment.setArguments(args1);
//                 Bundle args2 = new Bundle();
//                 args2.putInt("stId", stId);
//                 exercisesthematiclearingFragment.setArguments(args2);
                Bundle args3 = new Bundle();
                args3.putInt("stId", stId);
                args3.putString("orgId", orgId);
                testthematiclearningFragment.setArguments(args3);
//                 Bundle args4 = new Bundle();
//                 args4.putInt("stId", stId);
//                 args4.putString("orgId", orgId);
//                 args4.putString("orgName", orgName);
//                 args4.putString("rolename", rolename);
//                 args4.putString("adId", adId);
//                 args4.putInt("position", position);
//                 args4.putInt("ihveMark", ihveMark);
//                 examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                // list_title.add("学习");
                //list_title.add("习题练习");
                list_title.add("模拟");
                // list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(1);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("模拟")) {
                            tv_thembgm10.setBackgroundResource(R.drawable.tab_thempress);
                            //tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        }
//                         else if (textView.getText().toString().trim().equals("习题练习")) {
//                             tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
//                         }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 != 1 && qmenuMark1 != 1 && peMenuMark1 != 1 && emenuMark1 == 1) {
                fragments = new ArrayList<Fragment>();
//                 LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
//                 fragments.add(learnthematiclearningFragment);
//                 ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//                 fragments.add(exercisesthematiclearingFragment);
//                 TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
//                 fragments.add(testthematiclearningFragment);
                ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
                fragments.add(examinationthematiclearningFragment);

//                 Bundle args1 = new Bundle();
//                 args1.putInt("stId", stId);
//                 args1.putString("orgId", orgId);
//                 args1.putString("rolename", rolename);
//                 args1.putString("adId", adId);
//                 args1.putInt("position", position);
//                 learnthematiclearningFragment.setArguments(args1);
//                 Bundle args2 = new Bundle();
//                 args2.putInt("stId", stId);
//                 exercisesthematiclearingFragment.setArguments(args2);
//                 Bundle args3 = new Bundle();
//                 args3.putInt("stId", stId);
//                 args3.putString("orgId", orgId);
//                 testthematiclearningFragment.setArguments(args3);
                Bundle args4 = new Bundle();
                args4.putInt("stId", stId);
                args4.putString("orgId", orgId);
                args4.putString("orgName", orgName);
                args4.putString("rolename", rolename);
                args4.putString("adId", adId);
                args4.putInt("position", position);
                args4.putInt("ihveMark", ihveMark);
                examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                // list_title.add("学习");
                //list_title.add("习题练习");
                // list_title.add("模拟");
                list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(1);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("考试")) {
                            tv_thembgm10.setBackgroundResource(R.drawable.tab_thempress);
                            //tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        }
//                         else if (textView.getText().toString().trim().equals("习题练习")) {
//                             tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
//                         }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            }
            TabLayout2.setupWithViewPager(myviewpager);
            setIndicator(this, TabLayout2, TAB_MARGIN_DIP3, TAB_MARGIN_DIP3);
        } else if (marklist.size() == 2) {
            le_thematic.setVisibility(View.GONE);
            le_thematic1.setVisibility(View.GONE);
            le_thematic2.setVisibility(View.VISIBLE);
            le_thematic3.setVisibility(View.GONE);
            TabLayout2.setVisibility(View.VISIBLE);
            myviewpager.setVisibility(View.VISIBLE);
            int tmenuMark1 = sp.getInt("tmenuMark", 0);
            int qmenuMark1 = sp.getInt("qmenuMark", 0);
            int peMenuMark1 = sp.getInt("peMenuMark", 0);
            int emenuMark1 = sp.getInt("emenuMark", 0);
            if (tmenuMark1 == 1 && qmenuMark1 == 1 && peMenuMark1 != 1 && emenuMark1 != 1) {
                fragments = new ArrayList<Fragment>();
                LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
                fragments.add(learnthematiclearningFragment);
                ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
                fragments.add(exercisesthematiclearingFragment);
//        TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
//        fragments.add(testthematiclearningFragment);
//                 ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//                 fragments.add(examinationthematiclearningFragment);

                Bundle args1 = new Bundle();
                args1.putInt("stId", stId);
                args1.putString("orgId", orgId);
                args1.putString("rolename", rolename);
                args1.putString("adId", adId);
                args1.putInt("position", position);
                args1.putInt("seqTMark", seqTMark);
                args1.putInt("reapplyMark",reapplyMark);
                learnthematiclearningFragment.setArguments(args1);
                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                exercisesthematiclearingFragment.setArguments(args2);
//        Bundle args3 = new Bundle();
//        args3.putInt("stId", stId);
//        args3.putString("orgId", orgId);
//        testthematiclearningFragment.setArguments(args3);
//                 Bundle args4 = new Bundle();
//                 args4.putInt("stId", stId);
//                 args4.putString("orgId", orgId);
//                 args4.putString("orgName", orgName);
//                 args4.putString("rolename", rolename);
//                 args4.putString("adId", adId);
//                 args4.putInt("position", position);
//                 args4.putInt("ihveMark", ihveMark);
//                 examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                list_title.add("学习");
                list_title.add("习题练习");
                // list_title.add("测验");
                // list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(2);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("学习")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("习题练习")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 == 1 && qmenuMark1 != 1 && peMenuMark1 == 1 && emenuMark1 != 1) {
                fragments = new ArrayList<Fragment>();
                LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
                fragments.add(learnthematiclearningFragment);
//                 ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//                 fragments.add(exercisesthematiclearingFragment);
                TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
                fragments.add(testthematiclearningFragment);
//                 ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//                 fragments.add(examinationthematiclearningFragment);

                Bundle args1 = new Bundle();
                args1.putInt("stId", stId);
                args1.putString("orgId", orgId);
                args1.putString("rolename", rolename);
                args1.putString("adId", adId);
                args1.putInt("position", position);
                args1.putInt("seqTMark", seqTMark);
                args1.putInt("reapplyMark",reapplyMark);
                learnthematiclearningFragment.setArguments(args1);
//                 Bundle args2 = new Bundle();
//                 args2.putInt("stId", stId);
//                 exercisesthematiclearingFragment.setArguments(args2);
                Bundle args3 = new Bundle();
                args3.putInt("stId", stId);
                args3.putString("orgId", orgId);
                testthematiclearningFragment.setArguments(args3);
//                 Bundle args4 = new Bundle();
//                 args4.putInt("stId", stId);
//                 args4.putString("orgId", orgId);
//                 args4.putString("orgName", orgName);
//                 args4.putString("rolename", rolename);
//                 args4.putString("adId", adId);
//                 args4.putInt("position", position);
//                 args4.putInt("ihveMark", ihveMark);
//                 examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                list_title.add("学习");
                // list_title.add("习题练习");
                list_title.add("模拟");
                // list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(2);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("学习")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("模拟")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 == 1 && qmenuMark1 != 1 && peMenuMark1 != 1 && emenuMark1 == 1) {
                fragments = new ArrayList<Fragment>();
                LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
                fragments.add(learnthematiclearningFragment);
//                 ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//                 fragments.add(exercisesthematiclearingFragment);
//                 TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
//                 fragments.add(testthematiclearningFragment);
                ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
                fragments.add(examinationthematiclearningFragment);

                Bundle args1 = new Bundle();
                args1.putInt("stId", stId);
                args1.putString("orgId", orgId);
                args1.putString("rolename", rolename);
                args1.putString("adId", adId);
                args1.putInt("position", position);
                args1.putInt("seqTMark", seqTMark);
                args1.putInt("reapplyMark",reapplyMark);
                learnthematiclearningFragment.setArguments(args1);
//                 Bundle args2 = new Bundle();
//                 args2.putInt("stId", stId);
//                 exercisesthematiclearingFragment.setArguments(args2);
//                 Bundle args3 = new Bundle();
//                 args3.putInt("stId", stId);
//                 args3.putString("orgId", orgId);
//                 testthematiclearningFragment.setArguments(args3);
                Bundle args4 = new Bundle();
                args4.putInt("stId", stId);
                args4.putString("orgId", orgId);
                args4.putString("orgName", orgName);
                args4.putString("rolename", rolename);
                args4.putString("adId", adId);
                args4.putInt("position", position);
                args4.putInt("ihveMark", ihveMark);
                examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                list_title.add("学习");
                // list_title.add("习题练习");
                //list_title.add("模拟");
                list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(2);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("学习")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("考试")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 != 1 && qmenuMark1 == 1 && peMenuMark1 == 1 && emenuMark1 != 1) {
                fragments = new ArrayList<Fragment>();
//                 LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
//                 fragments.add(learnthematiclearningFragment);
                TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
                fragments.add(testthematiclearningFragment);
                ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
                fragments.add(exercisesthematiclearingFragment);
//                 ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//                 fragments.add(examinationthematiclearningFragment);

//                 Bundle args1 = new Bundle();
//                 args1.putInt("stId", stId);
//                 args1.putString("orgId", orgId);
//                 args1.putString("rolename", rolename);
//                 args1.putString("adId", adId);
//                 args1.putInt("position", position);
//                 learnthematiclearningFragment.setArguments(args1);

                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                args2.putString("orgId", orgId);
                testthematiclearningFragment.setArguments(args2);
                Bundle args3 = new Bundle();
                args3.putInt("stId", stId);
                exercisesthematiclearingFragment.setArguments(args3);
//                 Bundle args4 = new Bundle();
//                 args4.putInt("stId", stId);
//                 args4.putString("orgId", orgId);
//                 args4.putString("orgName", orgName);
//                 args4.putString("rolename", rolename);
//                 args4.putString("adId", adId);
//                 args4.putInt("position", position);
//                 args4.putInt("ihveMark", ihveMark);
//                 examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                //list_title.add("学习");
                list_title.add("模拟");
                list_title.add("习题练习");
                //list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(2);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("模拟")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("习题练习")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 != 1 && qmenuMark1 == 1 && peMenuMark1 != 1 && emenuMark1 == 1) {
                fragments = new ArrayList<Fragment>();
//                 LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
//                 fragments.add(learnthematiclearningFragment);
//                 TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
//                 fragments.add(testthematiclearningFragment);
                ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
                fragments.add(examinationthematiclearningFragment);
                ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
                fragments.add(exercisesthematiclearingFragment);
//                 Bundle args1 = new Bundle();
//                 args1.putInt("stId", stId);
//                 args1.putString("orgId", orgId);
//                 args1.putString("rolename", rolename);
//                 args1.putString("adId", adId);
//                 args1.putInt("position", position);
//                 learnthematiclearningFragment.setArguments(args1);

//                 Bundle args3 = new Bundle();
//                 args3.putInt("stId", stId);
//                 args3.putString("orgId", orgId);
//                 testthematiclearningFragment.setArguments(args3);
                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                args2.putString("orgId", orgId);
                args2.putString("orgName", orgName);
                args2.putString("rolename", rolename);
                args2.putString("adId", adId);
                args2.putInt("position", position);
                args2.putInt("ihveMark", ihveMark);
                examinationthematiclearningFragment.setArguments(args2);
                Bundle args4 = new Bundle();
                args4.putInt("stId", stId);
                exercisesthematiclearingFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                //list_title.add("学习");
                //list_title.add("模拟");
                list_title.add("考试");
                list_title.add("习题练习");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(2);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("考试")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("习题练习")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 != 1 && qmenuMark1 != 1 && peMenuMark1 == 1 && emenuMark1 == 1) {
                fragments = new ArrayList<Fragment>();
//                 LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
//                 fragments.add(learnthematiclearningFragment);
//                 ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//                 fragments.add(exercisesthematiclearingFragment);
                ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
                fragments.add(examinationthematiclearningFragment);
                TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
                fragments.add(testthematiclearningFragment);
//                 Bundle args1 = new Bundle();
//                 args1.putInt("stId", stId);
//                 args1.putString("orgId", orgId);
//                 args1.putString("rolename", rolename);
//                 args1.putString("adId", adId);
//                 args1.putInt("position", position);
//                 learnthematiclearningFragment.setArguments(args1);
//                 Bundle args2 = new Bundle();
//                 args2.putInt("stId", stId);
//                 exercisesthematiclearingFragment.setArguments(args2);

                Bundle args3 = new Bundle();
                args3.putInt("stId", stId);
                args3.putString("orgId", orgId);
                args3.putString("orgName", orgName);
                args3.putString("rolename", rolename);
                args3.putString("adId", adId);
                args3.putInt("position", position);
                args3.putInt("ihveMark", ihveMark);
                examinationthematiclearningFragment.setArguments(args3);
                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                args2.putString("orgId", orgId);
                testthematiclearningFragment.setArguments(args2);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                //list_title.add("学习");
                // list_title.add("习题练习");
                list_title.add("考试");
                list_title.add("模拟");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(2);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("考试")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("模拟")) {
                            tv_thembgm8.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm9.setBackgroundResource(R.drawable.tab_thempress);
                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                         else if (textView.getText().toString().trim().equals("考试")) {
//                             tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                             //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                             tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                         }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            }


            TabLayout2.setupWithViewPager(myviewpager);
            setIndicator(this, TabLayout2, TAB_MARGIN_DIP2, TAB_MARGIN_DIP2);

        } else if (marklist.size() == 3) {
            le_thematic.setVisibility(View.VISIBLE);
            le_thematic1.setVisibility(View.GONE);
            le_thematic2.setVisibility(View.GONE);
            le_thematic3.setVisibility(View.GONE);
            TabLayout2.setVisibility(View.VISIBLE);
            myviewpager.setVisibility(View.VISIBLE);
            int tmenuMark1 = sp.getInt("tmenuMark", 0);
            int qmenuMark1 = sp.getInt("qmenuMark", 0);
            int peMenuMark1 = sp.getInt("peMenuMark", 0);
            int emenuMark1 = sp.getInt("emenuMark", 0);
            if (tmenuMark1 == 1 && qmenuMark1 == 1 && peMenuMark1 != 1 && emenuMark1 == 1) {
                fragments = new ArrayList<Fragment>();
                LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
                fragments.add(learnthematiclearningFragment);
//        TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
//        fragments.add(testthematiclearningFragment);
                ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
                fragments.add(examinationthematiclearningFragment);
                ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
                fragments.add(exercisesthematiclearingFragment);
                Bundle args1 = new Bundle();
                args1.putInt("stId", stId);
                args1.putString("orgId", orgId);
                args1.putString("rolename", rolename);
                args1.putString("adId", adId);
                args1.putInt("position", position);
                args1.putInt("seqTMark", seqTMark);
                args1.putInt("reapplyMark",reapplyMark);
                learnthematiclearningFragment.setArguments(args1);
                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                args2.putString("orgId", orgId);
                args2.putString("orgName", orgName);
                args2.putString("rolename", rolename);
                args2.putString("adId", adId);
                args2.putInt("position", position);
                args2.putInt("ihveMark", ihveMark);
                examinationthematiclearningFragment.setArguments(args2);
                Bundle args4 = new Bundle();
                args4.putInt("stId", stId);
                exercisesthematiclearingFragment.setArguments(args4);
//        Bundle args3 = new Bundle();
//        args3.putInt("stId", stId);
//        args3.putString("orgId", orgId);
//        testthematiclearningFragment.setArguments(args3);

                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                list_title.add("学习");
                // list_title.add("测验");
                list_title.add("考试");
                list_title.add("习题练习");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(3);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("学习")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("考试")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_thempress);
                            //     tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);

                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
                        else if (textView.getText().toString().trim().equals("习题练习")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
                        }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 != 1 && qmenuMark1 == 1 && peMenuMark1 == 1 && emenuMark1 == 1) {
                fragments = new ArrayList<Fragment>();
//                 LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
//                 fragments.add(learnthematiclearningFragment);
                ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
                fragments.add(examinationthematiclearningFragment);
                TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
                fragments.add(testthematiclearningFragment);
                ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
                fragments.add(exercisesthematiclearingFragment);
//                 Bundle args1 = new Bundle();
//                 args1.putInt("stId", stId);
//                 args1.putString("orgId", orgId);
//                 args1.putString("rolename", rolename);
//                 args1.putString("adId", adId);
//                 args1.putInt("position", position);
//                 learnthematiclearningFragment.setArguments(args1);
                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                args2.putString("orgId", orgId);
                args2.putString("orgName", orgName);
                args2.putString("rolename", rolename);
                args2.putString("adId", adId);
                args2.putInt("position", position);
                args2.putInt("ihveMark", ihveMark);
                examinationthematiclearningFragment.setArguments(args2);

                Bundle args3 = new Bundle();
                args3.putInt("stId", stId);
                args3.putString("orgId", orgId);
                testthematiclearningFragment.setArguments(args3);
                Bundle args4 = new Bundle();
                args4.putInt("stId", stId);
                exercisesthematiclearingFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                //  list_title.add("学习");
                list_title.add("考试");
                list_title.add("模拟");
                list_title.add("习题练习");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(3);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("考试")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("模拟")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_thempress);
                            //     tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);

                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
                        else if (textView.getText().toString().trim().equals("习题练习")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
                        }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 == 1 && qmenuMark1 != 1 && peMenuMark1 == 1 && emenuMark1 == 1) {
                fragments = new ArrayList<Fragment>();
                LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
                fragments.add(learnthematiclearningFragment);
//                 ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//                 fragments.add(exercisesthematiclearingFragment);
                ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
                fragments.add(examinationthematiclearningFragment);
                TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
                fragments.add(testthematiclearningFragment);

                Bundle args1 = new Bundle();
                args1.putInt("stId", stId);
                args1.putString("orgId", orgId);
                args1.putString("rolename", rolename);
                args1.putString("adId", adId);
                args1.putInt("position", position);
                args1.putInt("seqTMark", seqTMark);
                args1.putInt("reapplyMark",reapplyMark);
                learnthematiclearningFragment.setArguments(args1);
//                 Bundle args2 = new Bundle();
//                 args2.putInt("stId", stId);
//                 exercisesthematiclearingFragment.setArguments(args2);

                Bundle args3 = new Bundle();
                args3.putInt("stId", stId);
                args3.putString("orgId", orgId);
                args3.putString("orgName", orgName);
                args3.putString("rolename", rolename);
                args3.putString("adId", adId);
                args3.putInt("position", position);
                args3.putInt("ihveMark", ihveMark);
                examinationthematiclearningFragment.setArguments(args3);
                Bundle args4 = new Bundle();
                args4.putInt("stId", stId);
                args4.putString("orgId", orgId);
                testthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                list_title.add("学习");
                //list_title.add("习题练习");
                list_title.add("考试");
                list_title.add("模拟");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(3);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("学习")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("考试")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_thempress);
                            //     tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);

                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
                        else if (textView.getText().toString().trim().equals("模拟")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
                        }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            } else if (tmenuMark1 == 1 && qmenuMark1 == 1 && peMenuMark1 == 1 && emenuMark1 != 1) {
                fragments = new ArrayList<Fragment>();
                LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
                fragments.add(learnthematiclearningFragment);
                TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
                fragments.add(testthematiclearningFragment);
                ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
                fragments.add(exercisesthematiclearingFragment);
//                 ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//                 fragments.add(examinationthematiclearningFragment);

                Bundle args1 = new Bundle();
                args1.putInt("stId", stId);
                args1.putString("orgId", orgId);
                args1.putString("rolename", rolename);
                args1.putString("adId", adId);
                args1.putInt("position", position);
                args1.putInt("seqTMark", seqTMark);
                args1.putInt("reapplyMark",reapplyMark);
                learnthematiclearningFragment.setArguments(args1);
                Bundle args2 = new Bundle();
                args2.putInt("stId", stId);
                args2.putString("orgId", orgId);
                testthematiclearningFragment.setArguments(args2);
                Bundle args3 = new Bundle();
                args3.putInt("stId", stId);
                exercisesthematiclearingFragment.setArguments(args3);
//                 Bundle args4 = new Bundle();
//                 args4.putInt("stId", stId);
//                 args4.putString("orgId", orgId);
//                 args4.putString("orgName", orgName);
//                 args4.putString("rolename", rolename);
//                 args4.putString("adId", adId);
//                 args4.putInt("position", position);
//                 args4.putInt("ihveMark", ihveMark);
//                 examinationthematiclearningFragment.setArguments(args4);
                //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
                list_title = new ArrayList<>();
                list_title.add("学习");
                list_title.add("模拟");
                list_title.add("习题练习");
                // list_title.add("考试");
                TabLayout2.setTabMode(TabLayout.MODE_FIXED);
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
                TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
                //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
                adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
                myviewpager.setAdapter(adapter);
                myviewpager.setOffscreenPageLimit(3);//解决滑动片段时缓存图片避免回收bug
                TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                    @Override
                    public void onTabSelected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTextColor(TabLayout2.getTabTextColors());
                        textView.setTypeface(Typeface.DEFAULT_BOLD);
                        if (textView.getText().toString().trim().equals("学习")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_thempress);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
                        } else if (textView.getText().toString().trim().equals("模拟")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_thempress);
                            //     tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);

                        }
//                else if(textView.getText().toString().trim().equals("测验"))
//                {
//                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                }
                        else if (textView.getText().toString().trim().equals("习题练习")) {
                            tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
                            //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
                            tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
                        }
                    }

                    @Override
                    public void onTabUnselected(TabLayout.Tab tab) {
                        View view = tab.getCustomView();
                        if (null == view) {
                            tab.setCustomView(R.layout.custom_tab_layout_text);
                        }
                        TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                        textView.setTypeface(Typeface.DEFAULT);
                    }

                    @Override
                    public void onTabReselected(TabLayout.Tab tab) {

                    }
                });
            }


            TabLayout2.setupWithViewPager(myviewpager);
            setIndicator(this, TabLayout2, TAB_MARGIN_DIP, TAB_MARGIN_DIP);
        } else if (marklist.size() == 4) {

            le_thematic.setVisibility(View.GONE);
            le_thematic1.setVisibility(View.VISIBLE);
            le_thematic2.setVisibility(View.GONE);
            le_thematic3.setVisibility(View.GONE);
            TabLayout2.setVisibility(View.VISIBLE);
            myviewpager.setVisibility(View.VISIBLE);
            fragments = new ArrayList<Fragment>();
            LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
            fragments.add(learnthematiclearningFragment);
            ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
            fragments.add(examinationthematiclearningFragment);
            TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
            fragments.add(testthematiclearningFragment);
            ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
            fragments.add(exercisesthematiclearingFragment);

            Bundle args1 = new Bundle();
            args1.putInt("stId", stId);
            args1.putString("orgId", orgId);
            args1.putString("rolename", rolename);
            args1.putString("adId", adId);
            args1.putInt("position", position);
            args1.putInt("seqTMark", seqTMark);
            args1.putInt("reapplyMark",reapplyMark);
            learnthematiclearningFragment.setArguments(args1);
            Bundle args2 = new Bundle();
            args2.putInt("stId", stId);
            args2.putString("orgId", orgId);
            args2.putString("orgName", orgName);
            args2.putString("rolename", rolename);
            args2.putString("adId", adId);
            args2.putInt("position", position);
            args2.putInt("ihveMark", ihveMark);
            examinationthematiclearningFragment.setArguments(args2);
            Bundle args3 = new Bundle();
            args3.putInt("stId", stId);
            args3.putString("orgId", orgId);
            testthematiclearningFragment.setArguments(args3);
            Bundle args4 = new Bundle();
            args4.putInt("stId", stId);
            exercisesthematiclearingFragment.setArguments(args4);
            //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
            list_title = new ArrayList<>();
            list_title.add("学习");
            list_title.add("考试");
            list_title.add("模拟");
            list_title.add("习题练习");
            TabLayout2.setTabMode(TabLayout.MODE_FIXED);
            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
            adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
            myviewpager.setAdapter(adapter);
            myviewpager.setOffscreenPageLimit(4);//解决滑动片段时缓存图片避免回收bug
            TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                @Override
                public void onTabSelected(TabLayout.Tab tab) {
                    View view = tab.getCustomView();
                    if (null == view) {
                        tab.setCustomView(R.layout.custom_tab_layout_text);
                    }
                    TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                    textView.setTextColor(TabLayout2.getTabTextColors());
                    textView.setTypeface(Typeface.DEFAULT_BOLD);
                    if (textView.getText().toString().trim().equals("学习")) {
                        tv_thembgm4.setBackgroundResource(R.drawable.tab_thempress);
                        tv_thembgm5.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm6.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm7.setBackgroundResource(R.drawable.tab_themnormal);
                    } else if (textView.getText().toString().trim().equals("考试")) {
                        tv_thembgm4.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm5.setBackgroundResource(R.drawable.tab_thempress);
                        tv_thembgm6.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm7.setBackgroundResource(R.drawable.tab_themnormal);

                    } else if (textView.getText().toString().trim().equals("模拟")) {
                        tv_thembgm4.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm5.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm6.setBackgroundResource(R.drawable.tab_thempress);
                        tv_thembgm7.setBackgroundResource(R.drawable.tab_themnormal);
                    } else if (textView.getText().toString().trim().equals("习题练习")) {
                        tv_thembgm4.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm5.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm6.setBackgroundResource(R.drawable.tab_themnormal);
                        tv_thembgm7.setBackgroundResource(R.drawable.tab_thempress);
                    }
                }

                @Override
                public void onTabUnselected(TabLayout.Tab tab) {
                    View view = tab.getCustomView();
                    if (null == view) {
                        tab.setCustomView(R.layout.custom_tab_layout_text);
                    }
                    TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
                    textView.setTypeface(Typeface.DEFAULT);
                }

                @Override
                public void onTabReselected(TabLayout.Tab tab) {

                }
            });
            TabLayout2.setupWithViewPager(myviewpager);
            setIndicator(this, TabLayout2, TAB_MARGIN_DIP1, TAB_MARGIN_DIP1);

        }


//        int isloop=1;
//        if(isloop==1) {
//            le_thematic.setVisibility(View.VISIBLE);
//            le_thematic1.setVisibility(View.GONE);
//            fragments = new ArrayList<Fragment>();
//            LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
//            fragments.add(learnthematiclearningFragment);
//            ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//            fragments.add(exercisesthematiclearingFragment);
////        TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
////        fragments.add(testthematiclearningFragment);
//            ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//            fragments.add(examinationthematiclearningFragment);
//
//            Bundle args1 = new Bundle();
//            args1.putInt("stId", stId);
//            args1.putString("orgId", orgId);
//            args1.putString("rolename", rolename);
//            args1.putString("adId", adId);
//            args1.putInt("position", position);
//            learnthematiclearningFragment.setArguments(args1);
//            Bundle args2 = new Bundle();
//            args2.putInt("stId", stId);
//            exercisesthematiclearingFragment.setArguments(args2);
////        Bundle args3 = new Bundle();
////        args3.putInt("stId", stId);
////        args3.putString("orgId", orgId);
////        testthematiclearningFragment.setArguments(args3);
//            Bundle args4 = new Bundle();
//            args4.putInt("stId", stId);
//            args4.putString("orgId", orgId);
//            args4.putString("orgName", orgName);
//            args4.putString("rolename", rolename);
//            args4.putString("adId", adId);
//            args4.putInt("position", position);
//            args4.putInt("ihveMark", ihveMark);
//            examinationthematiclearningFragment.setArguments(args4);
//            //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
//            list_title = new ArrayList<>();
//            list_title.add("学习");
//            list_title.add("习题练习");
//            // list_title.add("测验");
//            list_title.add("考试");
//            TabLayout2.setTabMode(TabLayout.MODE_FIXED);
//            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
//            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
//            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
//            //  TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
//            adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
//            myviewpager.setAdapter(adapter);
//            myviewpager.setOffscreenPageLimit(3);//解决滑动片段时缓存图片避免回收bug
//            TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
//                @Override
//                public void onTabSelected(TabLayout.Tab tab) {
//                    View view = tab.getCustomView();
//                    if (null == view) {
//                        tab.setCustomView(R.layout.custom_tab_layout_text);
//                    }
//                    TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
//                    textView.setTextColor(TabLayout2.getTabTextColors());
//                    textView.setTypeface(Typeface.DEFAULT_BOLD);
//                    if (textView.getText().toString().trim().equals("学习")) {
//                        tv_thembgm.setBackgroundResource(R.drawable.tab_thempress);
//                        tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                        //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//                    } else if (textView.getText().toString().trim().equals("习题练习")) {
//                        tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm1.setBackgroundResource(R.drawable.tab_thempress);
//                        //     tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
//
//                    }
////                else if(textView.getText().toString().trim().equals("测验"))
////                {
////                    tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
////                    tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
////                    tv_thembgm2.setBackgroundResource(R.drawable.tab_thempress);
////                    tv_thembgm3.setBackgroundResource(R.drawable.tab_themnormal);
////                }
//                    else if (textView.getText().toString().trim().equals("考试")) {
//                        tv_thembgm.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm1.setBackgroundResource(R.drawable.tab_themnormal);
//                        //    tv_thembgm2.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm3.setBackgroundResource(R.drawable.tab_thempress);
//                    }
//                }
//
//                @Override
//                public void onTabUnselected(TabLayout.Tab tab) {
//                    View view = tab.getCustomView();
//                    if (null == view) {
//                        tab.setCustomView(R.layout.custom_tab_layout_text);
//                    }
//                    TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
//                    textView.setTypeface(Typeface.DEFAULT);
//                }
//
//                @Override
//                public void onTabReselected(TabLayout.Tab tab) {
//
//                }
//            });
//
//
//            TabLayout2.setupWithViewPager(myviewpager);
//            setIndicator(this, TabLayout2, TAB_MARGIN_DIP, TAB_MARGIN_DIP);
//        }else if(isloop==2)
//        {
//            le_thematic.setVisibility(View.GONE);
//            le_thematic1.setVisibility(View.VISIBLE);
//            fragments = new ArrayList<Fragment>();
//            LearnthematiclearningFragment learnthematiclearningFragment = new LearnthematiclearningFragment();
//            fragments.add(learnthematiclearningFragment);
//            ExercisesthematiclearingFragment exercisesthematiclearingFragment = new ExercisesthematiclearingFragment();
//            fragments.add(exercisesthematiclearingFragment);
//           TestthematiclearningFragment testthematiclearningFragment = new TestthematiclearningFragment();
//          fragments.add(testthematiclearningFragment);
//            ExaminationthematiclearningFragment examinationthematiclearningFragment = new ExaminationthematiclearningFragment();
//            fragments.add(examinationthematiclearningFragment);
//
//            Bundle args1 = new Bundle();
//            args1.putInt("stId", stId);
//            args1.putString("orgId", orgId);
//            args1.putString("rolename", rolename);
//            args1.putString("adId", adId);
//            args1.putInt("position", position);
//            learnthematiclearningFragment.setArguments(args1);
//            Bundle args2 = new Bundle();
//            args2.putInt("stId", stId);
//            exercisesthematiclearingFragment.setArguments(args2);
//        Bundle args3 = new Bundle();
//        args3.putInt("stId", stId);
//        args3.putString("orgId", orgId);
//        testthematiclearningFragment.setArguments(args3);
//            Bundle args4 = new Bundle();
//            args4.putInt("stId", stId);
//            args4.putString("orgId", orgId);
//            args4.putString("orgName", orgName);
//            args4.putString("rolename", rolename);
//            args4.putString("adId", adId);
//            args4.putInt("position", position);
//            args4.putInt("ihveMark", ihveMark);
//            examinationthematiclearningFragment.setArguments(args4);
//            //将名称加载tab名字列表，正常情况下，我们应该在values/arrays.xml中进行定义然后调用
//            list_title = new ArrayList<>();
//            list_title.add("学习");
//            list_title.add("习题练习");
//            list_title.add("模拟");
//            list_title.add("考试");
//            TabLayout2.setTabMode(TabLayout.MODE_FIXED);
//            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(0)));
//            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(1)));
//            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(2)));
//            TabLayout2.addTab(TabLayout2.newTab().setText(list_title.get(3)));
//            adapter = new LearnCarAdapter(getSupportFragmentManager(), fragments, list_title);
//            myviewpager.setAdapter(adapter);
//            myviewpager.setOffscreenPageLimit(4);//解决滑动片段时缓存图片避免回收bug
//            TabLayout2.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
//                @Override
//                public void onTabSelected(TabLayout.Tab tab) {
//                    View view = tab.getCustomView();
//                    if (null == view) {
//                        tab.setCustomView(R.layout.custom_tab_layout_text);
//                    }
//                    TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
//                    textView.setTextColor(TabLayout2.getTabTextColors());
//                    textView.setTypeface(Typeface.DEFAULT_BOLD);
//                    if (textView.getText().toString().trim().equals("学习")) {
//                        tv_thembgm4.setBackgroundResource(R.drawable.tab_thempress);
//                        tv_thembgm5.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm6.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm7.setBackgroundResource(R.drawable.tab_themnormal);
//                    } else if (textView.getText().toString().trim().equals("习题练习")) {
//                        tv_thembgm4.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm5.setBackgroundResource(R.drawable.tab_thempress);
//                        tv_thembgm6.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm7.setBackgroundResource(R.drawable.tab_themnormal);
//
//                    }
//                else if(textView.getText().toString().trim().equals("模拟"))
//                {
//                    tv_thembgm4.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm5.setBackgroundResource(R.drawable.tab_themnormal);
//                    tv_thembgm6.setBackgroundResource(R.drawable.tab_thempress);
//                    tv_thembgm7.setBackgroundResource(R.drawable.tab_themnormal);
//                }
//                    else if (textView.getText().toString().trim().equals("考试")) {
//                        tv_thembgm4.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm5.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm6.setBackgroundResource(R.drawable.tab_themnormal);
//                        tv_thembgm7.setBackgroundResource(R.drawable.tab_thempress);
//                    }
//                }
//
//                @Override
//                public void onTabUnselected(TabLayout.Tab tab) {
//                    View view = tab.getCustomView();
//                    if (null == view) {
//                        tab.setCustomView(R.layout.custom_tab_layout_text);
//                    }
//                    TextView textView = tab.getCustomView().findViewById(android.R.id.text1);
//                    textView.setTypeface(Typeface.DEFAULT);
//                }
//
//                @Override
//                public void onTabReselected(TabLayout.Tab tab) {
//
//                }
//            });
//
//
//            TabLayout2.setupWithViewPager(myviewpager);
//            setIndicator(this, TabLayout2, TAB_MARGIN_DIP1, TAB_MARGIN_DIP1);
//        }

    }

    @Override
    public void requestData() {

    }


    public static void setIndicator(Context context, TabLayout tabs, int leftDip, int rightDip) {
        Class<?> tabLayout = tabs.getClass();
        Field slidingTabIndicator = null;
        try {
            slidingTabIndicator = tabLayout.getDeclaredField("slidingTabIndicator");
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }

        slidingTabIndicator.setAccessible(true);

        LinearLayout ll_tab = null;
        try {
            ll_tab = (LinearLayout) slidingTabIndicator.get(tabs);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        int left = (int) (getDisplayMetrics(context).density * leftDip);
        int right = (int) (getDisplayMetrics(context).density * rightDip);

        for (int i = 0; i < ll_tab.getChildCount(); i++) {
            View child = ll_tab.getChildAt(i);
            child.setPadding(0, 0, 0, 0);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
            params.leftMargin = left;
            params.rightMargin = right;
            child.setLayoutParams(params);
            child.invalidate();
        }
    }

    public static DisplayMetrics getDisplayMetrics(Context context) {
        DisplayMetrics metric = new DisplayMetrics();
        ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metric);
        return metric;
    }

    public static float getPXfromDP(float value, Context context) {
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value,
                context.getResources().getDisplayMetrics());
    }
}
